2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../jucer_Headers.h"
27 #include "jucer_PaintRoutinePanel.h"
28 #include "../properties/jucer_ColourPropertyComponent.h"
29 #include "../model/paintelements/jucer_PaintElementPath.h"
32 //==============================================================================
33 class ComponentBackgroundColourProperty
: public ColourPropertyComponent
,
34 private ChangeListener
37 ComponentBackgroundColourProperty (JucerDocument
& document_
,
38 PaintRoutine
& routine_
)
39 : ColourPropertyComponent ("background", false),
43 document
.addChangeListener (this);
46 ~ComponentBackgroundColourProperty()
48 document
.removeChangeListener (this);
51 void changeListenerCallback (ChangeBroadcaster
*)
56 void setColour (const Colour
& newColour
) { routine
.setBackgroundColour (newColour
); }
57 const Colour
getColour() const { return routine
.getBackgroundColour(); }
61 jassertfalse
// option shouldn't be visible
65 JucerDocument
& document
;
66 PaintRoutine
& routine
;
70 //==============================================================================
71 class GraphicsPropsPanel
: public Component
,
75 //==============================================================================
76 GraphicsPropsPanel (PaintRoutine
& paintRoutine_
,
77 JucerDocument
* document_
)
78 : paintRoutine (paintRoutine_
),
81 paintRoutine
.getSelectedElements().addChangeListener (this);
82 paintRoutine
.getSelectedPoints().addChangeListener (this);
84 addAndMakeVisible (propsPanel
= new PropertyPanel());
89 paintRoutine
.getSelectedPoints().removeChangeListener (this);
90 paintRoutine
.getSelectedElements().removeChangeListener (this);
96 //==============================================================================
99 propsPanel
->setBounds (4, 4, getWidth() - 8, getHeight() - 8);
102 void changeListenerCallback (ChangeBroadcaster
*)
114 XmlElement
* const state
= propsPanel
->getOpennessState();
120 Array
<PropertyComponent
*> props
;
121 props
.add (new ComponentBackgroundColourProperty (*document
, paintRoutine
));
123 propsPanel
->addSection ("Class Properties", props
);
128 propsPanel
->restoreOpennessState (*state
);
132 if (paintRoutine
.getSelectedElements().getNumSelected() == 1) // xxx need to cope with multiple
134 PaintElement
* const pe
= paintRoutine
.getSelectedElements().getSelectedItem (0);
138 Array
<PropertyComponent
*> props
;
139 pe
->getEditableProperties (props
);
141 propsPanel
->addSection (pe
->getTypeName(), props
);
145 if (paintRoutine
.getSelectedPoints().getNumSelected() == 1) // xxx need to cope with multiple
147 PathPoint
* const point
= paintRoutine
.getSelectedPoints().getSelectedItem (0);
151 Array
<PropertyComponent
*> props
;
152 point
->getEditableProperties (props
);
154 propsPanel
->addSection ("Path segment", props
);
160 PaintRoutine
& paintRoutine
;
161 JucerDocument
* document
;
163 PropertyPanel
* propsPanel
;
167 //==============================================================================
168 PaintRoutinePanel::PaintRoutinePanel (JucerDocument
& document_
,
169 PaintRoutine
& routine_
,
170 JucerDocumentHolder
* documentHolder
)
171 : EditingPanelBase (document_
,
172 new GraphicsPropsPanel (routine_
, &document_
),
173 new PaintRoutineEditor (routine_
, document_
, documentHolder
)),
178 PaintRoutinePanel::~PaintRoutinePanel()
183 void PaintRoutinePanel::updatePropertiesList()
185 ((GraphicsPropsPanel
*) propsPanel
)->updateList();
188 const Rectangle
<int> PaintRoutinePanel::getComponentArea() const
190 return ((PaintRoutineEditor
*) editor
)->getComponentArea();